import { Controller, Get, Post, Body, Param, Delete, Put, UseGuards, ParseIntPipe } from '@nestjs/common';
import { OperationTypesService } from './operation-types.service';
import { CreateOperationTypeDto } from './dto/create-operation-type.dto';
import { UpdateOperationTypeDto } from './dto/update-operation-type.dto';
import { OperationType } from './entities/operation-type.entity';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';

@Controller('operation-types')
@UseGuards(JwtAuthGuard)
export class OperationTypesController {
  constructor(private readonly operationTypesService: OperationTypesService) {}

  @Post()
  create(@Body() createOperationTypeDto: CreateOperationTypeDto): Promise<OperationType> {
    return this.operationTypesService.create(createOperationTypeDto);
  }

  @Get()
  findAll(): Promise<OperationType[]> {
    return this.operationTypesService.findAll();
  }

  @Get(':id')
  findOne(@Param('id', ParseIntPipe) id: number): Promise<OperationType> {
    return this.operationTypesService.findOne(id);
  }

  @Put(':id')
  update(
    @Param('id', ParseIntPipe) id: number,
    @Body() updateOperationTypeDto: UpdateOperationTypeDto,
  ): Promise<OperationType> {
    return this.operationTypesService.update(id, updateOperationTypeDto);
  }

  @Delete(':id')
  remove(@Param('id', ParseIntPipe) id: number): Promise<void> {
    return this.operationTypesService.remove(id);
  }

  @Put(':id/deactivate')
  deactivate(@Param('id', ParseIntPipe) id: number): Promise<OperationType> {
    return this.operationTypesService.deactivate(id);
  }

  @Put(':id/activate')
  activate(@Param('id', ParseIntPipe) id: number): Promise<OperationType> {
    return this.operationTypesService.activate(id);
  }
}